<?php

// Copyright 2019 Hackware SpA <human@hackware.cl>
// "Hackware Web Services Core" is released under the MIT License terms.

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTablemodelTestTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('foreigns', function (Blueprint $table) {
            $table->increments('id')->unsigned();
        });

        Schema::create('dumbs', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->string('attr1')->nullable();
            $table->string('attr2')->nullable();
            $table->string('custom_getter')->nullable();
            $table->string('custom_setter')->nullable();
            $table->timestamp('created_at')->nullable();
            $table->timestamp('updated_at')->nullable();
            $table->timestamp('deleted_at')->nullable();
            $table->timestamp('else_at')->nullable();
            $table->integer('foreign_id')->unsigned()->nullable();
            $table->foreign('foreign_id')->references('id')->on('foreigns');
            $table->integer('other_foreign_id')->unsigned()->nullable();
            $table->foreign('other_foreign_id')
                  ->references('id')
                  ->on('foreigns');
        });
    }

    public function down()
    {
        Schema::drop('dumbs');
        Schema::drop('foreigns');
    }
}
